//
//  ICCarouselVC.swift
//  ICFoundationFramework
//
//  Created by cuichengcheng on 2017/11/29.
//  Copyright © 2017年 cuichengcheng. All rights reserved.
//

import UIKit

class ICCarouselVC: UIViewController {
    lazy var carouselV = { () -> ICCarouselView in 
        let carouselV = ICCarouselView(frame:CGRect(x: 0, y: 70, width: self.view.bounds.size.width, height: 200));
        self.view.addSubview(carouselV);
        return carouselV;
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
    
        self.view.backgroundColor = .white
        self.title = "carousel"
        
        /**
         默认纵向滑动 没有标题 并且 如果传入text为nil 会自动按无标题显示
         默认开启定时器  自动滚动
         数据源 img 传入网络链接或本地图片 会自动匹配
         */
        carouselV.hasTitle = true
        carouselV.didSelectClo = { index in
            print("didSelect--\(index)")
        }
//        carouselV.autoScroll = false //关闭定时器
        carouselV.timeDuration = 1
        carouselV.scrollDirection = .horizontal
        carouselV.configData(list: [(img:"http://pic67.nipic.com/file/20150514/21036787_181947848862_2.jpg", text:"put some img look"),
                                    (img:"http://g.hiphotos.baidu.com/zhidao/pic/item/aec379310a55b3191510402645a98226cefc17fc.jpg", text:"ccc carousel auto"),
                                    (img:"http://f1.bj.anqu.com/down/OTc1ZQ==/allimg/1208/48-120S01A629.jpg", text:"111111111111")])
        
        let carouselV2 = ICCarouselView(frame:CGRect(x: 0, y: carouselV.frame.maxY+20, width: self.view.bounds.size.width, height: 200));
        carouselV2.didSelectClo = { index in
            print("didSelect--\(index)")
        }
        self.view.addSubview(carouselV2);
        carouselV2.timeDuration = 1.5
        carouselV2.configData(list: [(img:"http://a.hiphotos.baidu.com/image/pic/item/b812c8fcc3cec3fddc8130b5df88d43f869427b6.jpg", text:nil),
                                    (img:"http://img10.3lian.com/sc6/show/s11/19/20110711104956189.jpg", text:nil),
                                    (img:"http://pic1.win4000.com/wallpaper/2017-10-30/59f6c5aebced0.jpg", text:nil),
                                    (img:"http://imgsrc.baidu.com/image/c0%3Dshijue1%2C0%2C0%2C294%2C40/sign=4c1c2632b91bb0519b29bb6b5e13b0c1/f9198618367adab4af86315381d4b31c8701e448.jpg", text:nil),
                                    (img:"http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1304/19/c7/20028403_20028403_1366365586437.jpg", text:nil)])
        
        
        
        let carouselV3 = ICCarouselView(frame:CGRect(x: 0, y: carouselV2.frame.maxY+20, width: self.view.bounds.size.width, height: 200));
        carouselV3.scrollDirection = .horizontal
        carouselV3.didSelectClo = { index in
            print("didSelect--\(index)")
        }
        self.view.addSubview(carouselV3);
        //纯图片可以使用该参数设置数据源
        carouselV3.imgs = ["http://f.hiphotos.baidu.com/zhidao/pic/item/8b82b9014a90f60326b707453b12b31bb051eda9.jpg",
                           "http://attach.bbs.miui.com/forum/201605/11/163125xk1rvubkbqbqqu5b.jpg",
                           "http://e.hiphotos.baidu.com/zhidao/pic/item/203fb80e7bec54e75a1f3db0bb389b504ec26aa8.jpg",
                           "http://b.hiphotos.baidu.com/image/pic/item/d4628535e5dde71139f8a09badefce1b9d1661b1.jpg"]
        
        
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    deinit {
        carouselV.invalidateTimer()
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
